{php include wl_template('common/header');}
<style type='text/css'>
.trbody td{text-align: center;vertical-align:top;border-left:1px solid #ccc;border-bottom: 1px solid #ddd;}
.order-rank img{width:16px;height:16px;}
.js-remark,.js-admin-remark{word-break:break-all;overflow:hidden;background: #FDEEEE;color: #ED5050;padding: 5px 10px;}
td.goods-info{position:relative;padding-left:60px;}
.goods-info .img{position:absolute;top:50%;margin-top:-25px;background: url({IMAGE_LOADING}
) center center no-repeat;width:50px;height:50px;}
.goods-info span{white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: block;}
.status-text{cursor:pointer;}
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{border-top: 1px solid rgba(221, 221, 221, 0);}
.col-md-1{padding-right: 0px;}
.all-tips{margin-left: 65px;}
span.effect-time{font-size: 12px;display: block;font-weight: 500;}
.row.row-fix, .form-group.form-group-fix{margin-left: -15px;margin-right: -15px;width: 500px;}
button.btn.btn-default.daterange.daterange-date{float: left;position: absolute;z-index: 100;}
#sel_child{z-index: 10;width: 200px;position: absolute;display: none;}
.show1{display: block;}
.hide1{display: none;}
.sty{display: block;width: 100%;font-size: 13px;height: 46px;overflow: hidden;white-space: nowrap;line-height: 46px;text-overflow: ellipsis;text-align: center;}
.spe{display: inline-block;text-align: center;display: block;height: 33px;margin-left: -12px;padding-top: 0px;line-height: 33px;}
.table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{white-space: normal;}
span.ppp{text-align: center;display: inline-block;font-size: 14px;width: 100%;overflow: hidden;text-overflow: ellipsis;color: #e43;}
select#sel_parent{z-index: 1000;}
.nickname{margin-left: 94px;height: 34px;width: 200px;display: none;}
.col-xs-12.col-sm-6.col-sm-9.col-lg-6{z-index: 9999;}
.start-time{font-size: 12px;}
.end-time{font-size: 12px;}
</style>
<ul class="nav nav-tabs">
	<li class="active"><a href="javascript:;">优惠价列表</a></li>
</ul>
<div class="app-content">
	{if Customized::init('transfergift') > 0}
	<div class="panel panel-stat">
		<div class="panel-body">

			<div class="col-md-2">
				<div class="title">卡券总数(个)</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">{$all_num}</a>
				</div>
			</div>
			<div class="col-md-2">
				<div class="title">已使用(个)</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">{$use_num}</a>
				</div>
			</div>
			<div class="col-md-2">
				<div class="title">使用率(%)</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">{$use_rate}</a>
				</div>
			</div>
			<div class="col-md-2">
				<div class="title">已转赠(个)</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">{$transfer_num}</a>
				</div>
			</div>
			<div class="col-md-2">
				<div class="title">已过期(个)</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">{$end_num}</a>
				</div>
			</div>
		</div>
	</div>
	{/if}
	<div class="app-filter">
		<div class="filter-list">
			<form action="" method="get" class="form-horizontal" role="form" id="form1">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{MODULE_NAME}" />
				<input type="hidden" name="p" value="wlcoupon" />
				<input type="hidden" name="ac" value="couponlist" />
				<input type="hidden" name="do" value="merbercoupon" />
				<input type="hidden" name="status" value="{$_GPC['status']}" />
				<input type="hidden" name="type" value="{$_GPC['type']}" />
				<div class="form-group">
					<label class="col-sm-2 control-label">状态</label>
					<div class="col-sm-9">
						<div class="btn-group">
							<a href="{php echo wl_filter_url('status:0');}" class="btn {if intval($_GPC['status']) == 0}btn-primary{else}btn-default{/if}">不限</a>
							<a href="{php echo wl_filter_url('status:1');}" class="btn {if intval($_GPC['status']) == 1}btn-primary{else}btn-default{/if}">可使用</a>
							<a href="{php echo wl_filter_url('status:2');}" class="btn {if intval($_GPC['status']) == 2}btn-primary{else}btn-default{/if}">已使用</a>
						</div>
					</div>
				</div>
<!--				<div class="form-group">-->
<!--					<label class="col-sm-2 control-label">类型</label>-->
<!--					<div class="col-sm-9">-->
<!--						<div class="btn-group">-->
<!--							<a href="{php echo wl_filter_url('type:0');}" class="btn {if intval($_GPC['type']) == 0}btn-primary{else}btn-default{/if}">不限</a>-->
<!--							{if $diy['zkstatus']}-->
<!--							<a href="{php echo wl_filter_url('type:1');}" class="btn {if intval($_GPC['type']) == 1}btn-primary{else}btn-default{/if}">{if $diy['zkname']}{$diy['zkname']}{else}超级券{/if}</a>-->
<!--							{/if}-->
<!--							{if $diy['djstatus']}-->
<!--							<a href="{php echo wl_filter_url('type:2');}" class="btn {if intval($_GPC['type']) == 2}btn-primary{else}btn-default{/if}">{if $diy['djname']}{$diy['djname']}{else}代金券{/if}</a>-->
<!--							{/if}-->
<!--							{if $diy['tcstatus']}-->
<!--							<a href="{php echo wl_filter_url('type:3');}" class="btn {if intval($_GPC['type']) == 3}btn-primary{else}btn-default{/if}">{if $diy['tcname']}{$diy['tcname']}{else}套餐券{/if}</a>-->
<!--							{/if}-->
<!--							{if $diy['tgstatus']}-->
<!--							<a href="{php echo wl_filter_url('type:4');}" class="btn {if intval($_GPC['type']) == 4}btn-primary{else}btn-default{/if}">{if $diy['tgname']}{$diy['tgname']}{else}团购券{/if}</a>-->
<!--							{/if}-->
<!--							{if $diy['yhstatus']}-->
<!--							<a href="{php echo wl_filter_url('type:5');}" class="btn {if intval($_GPC['type']) == 5}btn-primary{else}btn-default{/if}">{if $diy['yhname']}{$diy['yhname']}{else}超级券{/if}</a>-->
<!--							{/if}-->
<!--						</div>-->
<!--					</div>-->
<!--				</div>-->
				<div class="form-group">
					<label class="col-sm-2 control-label">关键字</label>
					<div class="col-md-3">
						<select name="keywordtype" class="form-control">
							<option value="">关键字类型</option>
							<option value="1" {if $_GPC['keywordtype']==1}selected="selected"{/if}>超级券标题</option>
							<option value="2" {if $_GPC['keywordtype']==2}selected="selected"{/if}>按用户昵称</option>
						</select>
                    </div>
                    <div class="col-md-4">
                        <input type="text" name="keyword" class="form-control" value="{$_GPC['keyword']}"  placeholder="请输入关键字"/>
                    </div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">时间</label>
					<div class="col-md-2">
						<select name="timetype" class="form-control">
							<option {if $_GPC['timetype'] != 1} selected="selected" {/if} value="0">关闭</option>
							<option {if $_GPC['timetype'] == 1} selected="selected" {/if} value="1">开启</option>
						</select>
					</div>
					<div class="col-sm-7">
						{php echo tpl_select_time_info('time_limit', array('starttime' => date('Y-m-d',$starttime), 'endtime' => date('Y-m-d', $endtime)));}
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-9">
						<button class="btn btn-primary" id="search">筛选</button>
						<button class="btn btn-default min-width" name="export" type="submit" value="export"><i class="fa fa-download"></i>  导出记录</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript">
        $("#search").click(function(){
            $('#form1')[0].submit();
        });
	</script>
	<div class="app-table-list">
			<div class="panel-body table-responsive collapse in" id="order-template-item-4" style="padding: 0;">
				<table class="table table-bordered  table-hover">
					<thead style="background-color: #FFFFFF;">
					<tr>
						<th style="width:5%;" class="text-center"><input type="checkbox" onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" />全选</th>
						<th style="width:5%;">序号</th>
						<th style="width:20%;text-align:center;">超级券标题</th>
						<th style="width:15%; text-align:center;">所属商家</th>
						<th style="width:15%; text-align: center;">用户信息</th>
						<th style="width:10%; text-align:center;">超级券价格</th>
						<th style="width:15%; text-align:center;">超级券有效状态</th>
						<th style="width:15%; text-align: center;">操作</th>
					</tr>
					</thead>
					<tbody >
					{loop $merber_coupon $y $item}
						<tr>
							<td class="text-center" style="width:50px; height: auto;">
								<center><input type="checkbox" name="checkbox[]" class="checkbox" value="{$item['id']}" /></center>
							</td>
							<td style="width: 50px;" ><center>{php echo $y+1}</center></td>
							<td class="goods-info line-feed" style="width:190px;padding-left: 10px;">
								<div class="img"><img src="{IMAGE_PIXEL}" class="scrollLoading" data-url="{php echo tomedia($item['logo'])}" height="50" width="50" ></div>
								<div class="all-tips">
									<span class="">{$item['title']}</span>
									{if $item['concode']}<span class="">核销码:{$item['concode']}</span>{/if}
								</div>
							</td>
							<td class="text-center" style="width:120px; font-family: "Arial","Microsoft YaHei","黑体","宋体",sans-serif ;">{$item['storename']}</td>
							<td class="goods-info line-feed" style="width:170px;padding-left: 10px;">
								<div class="img"><img src="{IMAGE_PIXEL}" class="scrollLoading" data-url="{php echo tomedia($item['avatar'])}" height="50" width="50" ></div>
								<div class="all-tips">
									{$item['nickname']}
								</div>
								<div class="all-tips">
									{$item['mobile']}
								</div>

							</td>
							<!---->
							<td class="text-center" style="width:80px;">
								<!--{if $item['status']==0}<span class="label label-danger">未启用</span>{/if}
								{if $item['status']==1}<span class="label label-warning">已启用</span>{/if}							-->
								{if $item['orderno']}
								<span class="label label-info ">￥{$item['price']}</span>
								{else}
								<span class="label label-success ">免费</span>
								{/if}

							</td>
							<td class="text-center" style="width:160px;">
								<span class="effect-time">
								<span style="font-size: 12px; ">领取时间:{php echo  date('Y-m-d H:i:s',$item['createtime'])}</span><br/>
								{if $item['useflag']>0}
								<span style="font-size: 15px;color: #00B7EE;" ><a couponid="{$item['id']}" class="hexiaotime" href="javascript:;">查看核销详情</a></span><br/>
								{/if}
								{if $item['usetimes']>0 && $item['endtime'] < time()}
								<span style="font-size: 14px;font-weight: bold;font-family: '微软雅黑';color: orangered;">已过期</span><br/>
								{else if empty($item['useflag']) && $item['usetimes']>0}
								<span style="font-size: 14px;font-weight: bold;font-family: '微软雅黑';color: #04BE02;">未使用</span><br/>
								<span style="font-size: 12px; ">过期时间:{php echo  date('Y-m-d H:i:s',$item['endtime'])}</span>
								{else if $item['useflag'] > 0 && $item['usetimes']>0}
								<span style="font-size: 12px; ">过期时间:{php echo  date('Y-m-d H:i:s',$item['endtime'])}</span>
								{else if $item['usetimes'] == 0}
								<span style="font-size: 14px;font-weight: bold;font-family: '微软雅黑';color: #23c6c8;">已完成</span><br/>
								{else}
								<span style="font-size: 14px;font-weight: bold;font-family: '微软雅黑';color: grey;">已退款</span><br/>
								{/if}
								</span>
							</td>
							<td class="text-center" style="width:50px;">
								<div class="text-center">
									{if $item['usetimes'] > 0 && $item['endtime'] > time()}
									<a class='op'  data-toggle='ajaxPost' href="{php echo web_url('wlcoupon/couponlist/writroff',array('id'=>$item['id']))}" data-confirm="确认核销此卡券?">核销</a> -
									{/if}
									<a class='op'  data-toggle='ajaxPost' href="{php echo web_url('wlcoupon/couponlist/deleteCoupon',array('id'=>$item['id']))}" data-confirm="确认删除此卡券?" >删除</a>
									{if $item['trflag'] > 0}
									 - <a class='op'  data-toggle='ajaxModal' href="{php echo web_url('wlcoupon/couponlist/record_transfer',array('id'=>$item['id']))}">转赠记录</a>
									{/if}
								</div>
							</td>
						</tr>
						{/loop}
						</tbody>
					</table>
				</div>
				<div class="app-table-foot clearfix">
					<div class="pull-left" id="de1">
						<a href="javascript:;" class="btn btn-default min-width js-batch js-delete">删除选中记录</a>
					</div>
					<div class="pull-right">
						{$pager}
					</div>
				</div>
		</div>
	</div>
	<div id="modal-module-gift" class="modal fade" tabindex="-1">
		<div class="modal-dialog" style='width: 620px;'>
			<div class="modal-content">
				<div class="modal-header">
					<button aria-hidden="true" data-dismiss="modal" onclick="asd()" class="close" type="button">×</button>
					<h3>核销详情</h3>
				</div>
				<div class="modal-body">
					<div>剩余使用次数：<span id="lasttime">{{d.times}}</span></div>
					<div id="xiangq"></div>
				</div>
				<div class="modal-footer" style="padding: 5px 15px;">
					<a class="btn btn-primary js-order-remark-post" order-id="" onclick="asd()" data-dismiss="modal" aria-hidden="true">确定</a>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	require(['jquery', 'util'], function($, util){
		$('.js-copy').each(function(){
			var id=$(this).attr('data-id');
			util.clip($("#js-copy"+id), $(this).attr('data-url'));
		});
	});
	$('.hexiaotime').click(function(){
		popwin = $('#modal-module-gift').modal();
		var id = $(this).attr('couponid');
		$.post("{php echo web_url('wlcoupon/couponlist/hexiaotime')}",{id:id},function(d){
			if(!d.errno){
				$('#xiangq').html('');
				$('#lasttime').text(d.times);
				var len = d.data.length;
				if (len == 1) {
					var html = "<div>核销时间："+d.data[0]+"</div>";
					$("#xiangq").append(html);
				}else{
					for(var i=0;i<len;i++){
						var c = i+1;
						var html = "<div>第"+c+"次核销时间："+d.data[i]+"</div>";
						$("#xiangq").append(html);
					}	
				}
				
			}
		},"json");
		$('#double').hide();
	});
	function asd(){
		$('#double').show();
	}
</script>
<script type="text/javascript">
	$('#output').click(function(){
		var orderType = '{$_GPC['orderType']}';
		var status = '{$_GPC['status']}';
		var paytype = '{$_GPC['pay_type']}';
		var keywordtype = '{$_GPC['keywordtype']}';
		var keyword = '{$_GPC['keyword']}';
		var timetype = '{$_GPC['timetype']}';
		var times = "{$_GPC['time']['start']}";
		var timee = "{$_GPC['time']['end']}";
		location.href = "{php echo web_url('order/order/output')}&orderType="+orderType+"&status="+status+"&paytype="+paytype+"&keywordtype="+keywordtype+"&keyword="+keyword+"&timetype="+timetype+"&times="+times+"&timee="+timee;
	});
	$(function(){
		$('[name="rank_all"]').click(function() {
			var checked = this.checked;
			$('.js-rank').find('input:checkbox').each(function() {
				this.checked = checked;
			});
		});
		$('#export').click(function() {
			if ($('[name="selecttime[start]"]').val() == '') {
				alert('请选择下单时间');
				$(this).focus();
				return false;
			};
			$(this).attr('type', 'submit').submit();
		});
		
		$('.order-rank').each(function(){
			o.rank(this);
		});
		
		// 编辑
		$('.js-order-edit-remark').click(function(){
			
		});
		
		// 修改价格
		$('.js-order-edit-payment').click(function() {
			var $this = $(this);
			var order_id = $this.attr('order-id');
			
			o.editPayment(order_id, function(order) {
				$this.parent()
					.find('.js-order-payment').find('.js-fee').html(order.payment).end().end()
					.find('.js-order-post-fee').find('.js-fee').html(order.post_fee);
				
				var adjust_fee = parseFloat(order.adjust_fee);
				if (adjust_fee){
					var title = adjust_fee > 0 ? '加价' : '减价';
					console.log(title);
					$this.parent()
						.find('.js-order-adjust-fee').show()
						.find('.js-title').text(title).end()
						.find('.js-fee').text(adjust_fee.toFixed(2));
				} else {
					$this.parent()
						.find('.js-order-adjust-fee').hide()
						.find('.js-title').text('').end()
						.find('.js-fee').text('');
				}
			});
		});
		$('.js-bdelete').click(function(e) {
			e.stopPropagation();
			var _this = $(this).parent().parent().parent().parent().parent().parent();
			var order_id = $(this).attr('order-id');
			util.nailConfirm(this, function(state) {
				if(!state) return;
				$.post("{php echo web_url('order/order/confirmHexiao')}",{id:order_id},function(d){
				if(!d.errno){
					_this.remove();
					util.tips(d.message, 2000);
				}
			},"json");
			}, {html: '确认核销?'});
			
		});
		$('.order-list').delegate('.js-order-cancel', 'click', function(){
			var $this = $(this);
			var order_id = $this.attr('order-id');
			o.adminClose(order_id, function(order){
				console.log(order);
				$this.parent().parent().find('.status-text').text(order.status_text).data('title', order.status_content + '<br/>关闭原因:' + order.cancel_reason);
				$this.remove();
			});
		});
		
		//发货
		$('.order-list').delegate('.js-order-send', 'click', function(){
			var $this = $(this);
			var order_id = $this.attr('order-id');
			o.send(order_id, function(order) {
				$this.parent().parent()
					.append($('<p class="express b">物流信息</p>').data('express', order.express_company).data('express-no', order.express_no))
					.find('.status-text').text(order.status_text).data('title', order.status_content);
				$this.remove();
			});
		});
		
		//删除
		$('.order-list').delegate('.js-remove', 'click', function(e){
			e.stopPropagation();
			var $this = $(this);
			var id = $this.attr('order-id');
			util.nailConfirm(this, function(state) {
				if(!state) return;
				$.post("{php echo web_url('wlcoupon/couponlist/deleteCoupon')}", { id : id }, function(data){
					if(!data.errno){
					$this.parent().parent().parent().remove();
					util.tips("删除成功！");
					};
				}, 'json');
			}, {html: '确认删除?'});
		});
		$('#de1').delegate('.js-delete','click',function(e){
			e.stopPropagation();
			var order_ids = [];
			var $checks=$('.checkbox:checkbox:checked');
			$checks.each(function() {
				if (this.checked) {
					order_ids.push(this.value);
				};
			});
				var $this = $(this);
				var ids = order_ids;
			//	alert(ids);
				util.nailConfirm(this, function(state) {
				if(!state) return;
					$.post("{php echo web_url('wlcoupon/couponlist/deleteCoupon')}", { ids : ids }, function(data){
						if(!data.errno){
						util.tips("删除成功！");
						location.reload();
						};
					}, 'json');
				}, {html: '确认删除?'});
			});
		});
		
$(document).ready(function(){
	$('#box1').attr("style",'');
})


</script>

{php include wl_template('common/footer');}